package com.animal.service.impl;

import com.animal.entity.AnUser;
import com.animal.mapper.AnMeansMapper;
import com.animal.mapper.AnUserMapper;
import com.animal.service.AnUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author animal
 * @since 2022-01-28
 */
@Service
public class AnUserServiceImpl extends ServiceImpl<AnUserMapper, AnUser> implements AnUserService {
    @Autowired
    AnUserMapper anUserMapper;
    @Autowired
    AnMeansMapper anMeansMapper;
    @Override
    public List<AnUser> lookAll(int size, int current) {
        Page<AnUser> userPage = new Page<>(current,size);

        Page<AnUser> userPages=  anUserMapper.selectPage(userPage,null);



        List<AnUser> list =userPages.getRecords();
        for(AnUser a:list){
            QueryWrapper queryWrapper=new QueryWrapper();
            queryWrapper.eq("user_id",a.getUserId());
            a.setAnMeans(anMeansMapper.selectOne(queryWrapper));
        }
        return list;
    }
}
